let page = 1;
let line = 8;
setPage();
async function setPage() {

  const urlObj = myGetUrlValue();
  console.log(urlObj);

  const res = await myPromiseAjax('../server/goods_list.php', 'get', { cat_one_id: urlObj.code_one_id , page: page, line: line }, 'json');
  console.log(res);

  let str = '';
  res.data.forEach(item => {
    str += `
      <li class="list-item">
        <div class="panel panel-primary">
          <div class="panel-body">
            <ol class="breadcrumb">
              <li><a href="#">${item.cat_one_id}</a></li>
              <li><a href="#">${item.cat_two_id}</a></li>
              <li class="active">${item.cat_three_id}</li>
            </ol>
          </div>
          <div class="panel-footer">
            <div class="row">
              <div class="">
                <div class="thumbnail">
                  <img src="${item.goods_big_logo}" alt="...">
                  <div class="caption">
                    <h3>${item.goods_name}</h3>
                    <p>
                      <i class="glyphicon glyphicon-yen"></i>
                      <span>${item.goods_price}</span>
                    </p>
                    <p><a href="javascript:;" class="btn btn-primary" role="button">查找相似商品</a>
                       <a href="./detail.html?goods_id=${item.goods_id}" class="btn btn-danger" role="button">查看商品详情</a>
                    </p>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </li>

  `;
  })

  $('.container ul').html(str);


  $('.box').pagination({
    pageCount: res.sumPage,
    totalData:res.row,
    current:res.page,
    showData:res.line,
    prevCls:'prev',
    nextCls:'next',
    prevContent:'上一页',
    nextContent:'下一页',
    activeCls:'active',
    mode:'fixed',
    count:4,
    coping:true,
    homePage:'首页',
    endPage:'末页',
    isHide:true,
    keepShowPN:true,
    jump:true,
    callback:function(value){
      console.log(value)
      console.log(value.getCurrent());

      page=value.getCurrent();
      setPage();
    }
  })
}
